const {tSstSsDisabledRefreshToken } = require("../db/init");
// Static methods:
tSstSsDisabledRefreshToken.associate = models => {
    models.tSstSsDisabledRefreshToken.belongsTo(models.User, {
        foreignKey: "UserId",
        as: 'user'
    });
}

tSsDisabledRefreshToken.createOrFind = function({ token, userId }) {
    const where = {
        token
    };

    const defaults = {
        token:token,
        UserId:userId
    };

    const query = {
        where,
        defaults
    };
    return this.findOrCreate(query);
}

tSsDisabledRefreshToken.selectAll = function({ token }) {
    const where = {
        token
    };
    const query = { where };
    return this.findAll(query);
}
// Static methods\

// Instance methods:
tSsDisabledRefreshToken.prototype.toJSON = function() {
    const values = Object.assign({}, this.get());
    return values;
}
// Instance methods\

module.exports = tSsDisabledRefreshToken;
